﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CubicFWNet.Data.Models;
using CubicFWNet.Data.ViewModal;

namespace CubicFWNet.Data.SystemManager
{
    public class InventoryChangeApplyRepository: RepositoryBase<InventoryChangeApply>
    {
        public IEnumerable<InventoryChangeApplyView> GetInventoryChangeApplyList()
        {
            var result = from ICA in dbcontext.InventoryChangeApplys
                         join order in dbcontext.Orders on ICA.OrderId equals order.Id
                         join user in dbcontext.Users on order.UserId equals user.Id
                         join product in dbcontext.Products on ICA.ProductId equals product.Id

                         select new InventoryChangeApplyView
                         {
                             Id = ICA.Id,
                             OrderId = ICA.OrderId,
                             ProductId = ICA.ProductId,
                             ApplyAmount = ICA.ApplyAmount,
                             FinishAmount = ICA.FinishAmount,
                             ApplyTime = ICA.ApplyTime,
                             CreateTime = ICA.CreateTime,
                             CreatorId = ICA.CreatorId,
                             Status = ICA.Status,
                             Memo = ICA.Memo,

                             ProductName = product.Name,
                             Number = order.Number,
                             ApplyUserName = user.RealName,
                         };
            return result;
        }
    }
}
